home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 2002 January / PC Answers January 2002.7z / PC Answers January 2002.bin / graphics / freepixl / _SETUP.1 / imgprint.pxl < prev    next >
Text File  |  2000-12-23  |  6KB  |  230 lines

  1. {    Filename    :     imgprint.pxl
  2.      Purpose    :    print an image file from a command line
  3.     Date        :    21 nov 98
  4.     Author    :        S.Dibbs, VYSOR Integration Inc
  5. History:
  6.  
  7.     Version    :  1.0    RELEASE
  8.     Update        :  
  9.     Date        :  
  10.  
  11. --------------------------------------------------------------------------}
  12. Initialize: {only one instance allowed}
  13.     UseCoordinates(PIXEL)
  14.     Title$ = "PiXCL Image Print Utility"                                  
  15.     WinExist(Title$,Res)
  16.     If Res = 0 Then Goto One_Instance
  17.     Beep
  18.     WinSetActive(Title$,Res)
  19.     WinShow(Title$,RESTORE,Res)
  20.     End
  21. One_Instance:
  22.     UseCaption(Title$) {change the title}
  23.     GetCmdLine(CommandLine$)
  24.     {MessageBox(OK,1,INFORMATION,CommandLine$,"Current Command Line",Res)}
  25.     GoSub ProcessCmdLine {returns Done}
  26.  
  27.     WinLocate(Title$,354,118,906,513,Res)                
  28.     UseBackground(TRANSPARENT,210,218,251)     
  29.     WinShow(Title$,NOTOPMOST,Res) 
  30.     DrawBackGround
  31.     DirGet(SourceDir$) {used later for library function calls}
  32.  
  33.     DragAcceptFile(ENABLE,AcceptFile)
  34.     AutoProgressBar(DISABLE)
  35.  
  36.     InfoMenu(REMOVE)
  37.     WaitInput(100)
  38.     SetMenu("&File",IGNORE,
  39.         "&New",CreatingFile,
  40.         "&Open",OpeningFile,
  41.         "&Save",SavingFile,
  42.         SEPARATOR,
  43.         "E&xit!",Terminate,
  44.         ENDPOPUP,
  45.         "&View",IGNORE,
  46.         "&ToolBar",ViewToolBar,
  47.         "&StatusBar",ViewStatusBar,
  48.         ENDPOPUP,
  49.         "&Information",IGNORE,
  50.         "&Concept",Concept,
  51.         "&Help",ShowAppHelp,
  52.         SEPARATOR,
  53.         "&About",About,
  54.         ENDPOPUP)
  55.  
  56.     GoSub MakeToolbar
  57.     ChangeMenuItem("&ToolBar",CHECK,TBRes)
  58.  
  59.         
  60.     StatusWindow(ENABLE,BOTTOM,2,200,-1,0,0)
  61.     DrawStatusWinText(0,"Ready")
  62.     If Done = 0 Then DrawStatusWinText(0,"Print command failed")
  63.  
  64.     ChangeMenuItem("&StatusBar",CHECK,SBRes)
  65.  
  66.         
  67.  
  68.     
  69. Wait_for_Input:
  70.     WaitInput()
  71.  
  72. Terminate:
  73.     End
  74.  
  75.  
  76. Concept:
  77.     MessageBox(OK,1,INFORMATION,
  78. "This is a skeleton of a PiXCL application.  You could briefly
  79. describe your application's function here, or provide some
  80. basic help information.",
  81.     "PiXCL Skeleton Concept",Res)
  82.  
  83.     Goto Wait_for_Input
  84.  
  85. ShowAppHelp:
  86.     {An application Help file usually has the same name as the application.}
  87.     Winhelp("test.hlp",CONTENTS,"")
  88.  
  89.     Goto Wait_for_Input
  90.  
  91. About:
  92.     AboutUser( Title$,
  93.       "Print an image from a command line.",
  94.     "Four Lines of additional information goes here, perhaps contact information and Web addresses")
  95.  
  96.     Goto Wait_for_Input
  97.  
  98. ViewToolBar:
  99.     GetMenuStatus("&ToolBar",CHECKED,Res)
  100.     If Res = 0
  101.         GoSub MakeToolbar
  102.         ChangeMenuItem("&ToolBar",CHECK,Res)
  103.     Else
  104.         Toolbar()
  105.         ChangeMenuItem("&ToolBar",UNCHECK,Res)
  106.     Endif
  107.     Goto Wait_for_Input
  108.  
  109. ViewStatusBar:
  110.     GetMenuStatus("&StatusBar",CHECKED, Res)
  111.     If Res = 0
  112.         StatusWindow(ENABLE,BOTTOM,2,200,-1,0,0)
  113.         DrawStatusWinText(0,"Ready")
  114.         ChangeMenuItem("&StatusBar",CHECK,Res)
  115.     Else
  116.         StatusWindow(DISABLE,BOTTOM,2,200,-1,0,0)
  117.        ChangeMenuItem("&StatusBar",UNCHECK,Res)
  118.     Endif
  119.     Goto Wait_for_Input
  120.  
  121. CreatingFile:
  122.     {TODO: add file handling here}
  123.     {MessageBox(OK,1,INFORMATION,"No operation code for this button.","File New",Res)}
  124.     ListLoadedBitmaps(List$,"|",Count)
  125.     DrawText(10,30,List$)
  126.     DrawBitmap(10,60,Image$)
  127.     Goto Wait_for_Input
  128.  
  129. OpeningFile:
  130.     {TODO: add file handling here}
  131.     {MessageBox(OK,1,INFORMATION,"No operation code for this button.","File Open",Res) }
  132.     WaitInput(1)
  133.     UseCursor(WAIT)
  134.     Chr(10,Delimiter$)
  135.     Name$ = ""
  136.     EnumPrinters(LOCAL,NONSHARED,Name$,ONE,Delimiter$,PrinterNameList$,
  137.             PrinterDescList$,Res)
  138.     Len(PrinterNameList$,Res1)
  139.     DrawStatusWinText(1,PrinterNameList$) 
  140.     Str(Res1,Res1$)   DrawStatusWinText(1,Res1$)
  141.     UseCursor(ARROW)
  142.     If Res = 1
  143.         DrawTextExt(10,30,400,200,PrinterNameList$,LEFT)
  144.     Else
  145.         DrawStatusWinText(0,"EnumPrinters failed")
  146.         WaitInput(1500)
  147.         DrawStatusWinText(0,"Ready...")
  148.     Endif
  149.     Goto Wait_for_Input
  150.  
  151. SavingFile:
  152.     {TODO: add file handling here}
  153.     MessageBox(OK,1,INFORMATION,"No operation code for this button.","File Save",Res)
  154.     Goto Wait_for_Input
  155.  
  156.  
  157. PrintingFile:
  158.     WaitInput(1)
  159.     Filter$ = "TIFF files (*.tif),*.tif"
  160.     Label$ = "Select a file to print"    
  161.     InitFile$ = "*.tif"
  162.     InitDir$ = SourceDir$
  163.     FileGet(Filter$,InitFile$,InitDir$,Label$,CHANGEDIR,Image$)
  164.     If Image$ <> ""
  165.         PrintBitmap(Image$,PRINT_PAGERES, Res)
  166.         If Res = 0 Then DrawStatusWinText(0,"Print command failed")
  167.     Endif
  168.     Goto Wait_for_Input
  169.  
  170.  
  171. AcceptFile:
  172.     GetDragList(FileList$)
  173.     {TODO: add file list handling here, or delete this whole label handler}
  174.     Goto Wait_for_Input
  175.     
  176.  
  177. {--- Style Suggestion: place all subroutines at the end of the script.}
  178.  
  179. MakeToolbar: {subroutine}
  180.     Toolbar(    RAISED, PXL_SMALL,
  181.         NULL, NULL, SEPARATOR, "", Wait_for_Input,
  182.         PXL_NEW, ENABLED, STD, "FileNew", CreatingFile,
  183.         PXL_OPEN, ENABLED, STD, "Enumerate Printers", OpeningFile,
  184.         PXL_SAVE, ENABLED, STD, "FileSave", SavingFile,
  185.         NULL, NULL, SEPARATOR, "", Wait_for_Input,
  186.         PXL_PRINT,  ENABLED, STD,"Print", PrintingFile,
  187.         NULL, NULL, SEPARATOR, "", Wait_for_Input,
  188.         PXL_SHOHLP, ENABLED, STD,"Show Help",ShowAppHelp)
  189.  
  190.     Return
  191.  
  192. ProcessCmdLine: {subroutine: check CommandLine$ for imgprint.exe}
  193.     Done = 0
  194.     Len(CommandLine$,Long)
  195.     If Long <= 9
  196.         MessageBox(OK,1,EXCLAMATION,"No image file specified.","Incomplete command line",Res)
  197.         End
  198.     Endif
  199.  
  200.     Right(CommandLine$,3,Ext$)
  201.     Lcase(Ext$)
  202.     If Ext$ = "exe" Then Done = 0   Return
  203.  
  204.     {get the file to print ... arg#1}
  205.     InStr(CommandLine$," ",Loc)
  206.     RightOf(CommandLine$,Loc,CommandLine$)
  207.     StrRev(CommandLine$)   {remove leading and trailing spaces, if any}
  208.     Trim(CommandLine$)
  209.     StrRev(CommandLine$)
  210.     Trim(CommandLine$)
  211.     Image$ = CommandLine$
  212.     Trim(CommandLine$)
  213.     Trim(Image$)
  214.     FreeVar(CommandLine$)
  215.     FileExist(Image$,Res)
  216.     If Res = 0 
  217.         MessageBox(OK,1,EXCLAMATION,Image$,"Image File does not exist",Res)
  218.         End
  219.     Endif
  220. {
  221.     MessageBox(YESNO,2,QUESTION,"Load this file?",Image$,Res)
  222.     If Res = 2 Then Done = 1 Return
  223. }
  224.     LoadBitmap(Image$,FULL)
  225.     PrintBitmap(Image$,PRINT_PTRRES, Res)
  226.     If Res = 1 Then End
  227.     Done = 0
  228.  
  229.     Return
  230.